package com.aubrey.threadDemo.create;

public class ThreadSynchronized {
	public static void main(String[] args) {
		PrintName print = new PrintName();
		new Thread(new Runnable() {
			@Override
			public void run() {
				while(true) {
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					print.pirnt("广州广州");
				}
				
				
			}
		}).start();
		new Thread(new Runnable() {
			@Override
			public void run() {
				while(true) {
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					print.pirnt("深圳深圳");
				}
				
				
			}
		}).start();
	}
}

class PrintName{
	
	public synchronized void pirnt(String name) {
//		synchronized(PrintName.class) {
			for (int i = 0; i < name.length(); i++) {
				System.out.print(name.charAt(i));
			}
			System.out.println();
//		}
	}
}
